package com.colin.aiyi.dao.ImpxUtils3_de;

import com.colin.aiyi.app.Constant;
import com.colin.aiyi.entity.response.YiJuAndYiShuoResponse;
import com.colin.aiyi.presenter.Interface.Callback;

import org.xutils.http.RequestParams;

/**
 * Created by hl on 2017/5/31.
 */
@Deprecated
public class ImpYuLu extends AbsServicexUtils<YiJuAndYiShuoResponse>{
    @Override
    public void getAllT(Callback<YiJuAndYiShuoResponse> callback, String... value) {
        super.getAllT(callback, value);
        if (value.length<2)
        {
            return;
        }
//        1:人气 2：最新  3已购买 4我观看的,5我收藏的
        switch (value[value.length-1])
        {
            case Constant.TAB_TYPE_LIST:
               getYuLuList(value[0]);
                break;
            case Constant.TAB_TYPE_LIKE:
                getYuLuWithLike(value[0]);
                break;
        }
    }

    /*    pageNum	否	Integer	页码 （默认为1）
  pageSize	否	Integer	每页显示条数（默认为10）*/
    private void getYuLuList(String pageNum){
        RequestParams params=new RequestParams(Constant.DISCOURSE_list);
        params.addBodyParameter("pageSize",Constant.PAGESIZE+"");
        params.addBodyParameter("pageNum",pageNum+"");
        sendToServer(params);
    }

    /*    pageNum	否	Integer	页码 （默认为1）
    pageSize	否	Integer	每页显示条数（默认为10）*/
    private void getYuLuWithLike(String pageNum){
        RequestParams params=new RequestParams(Constant.DISCOURSE_discourseLikeList);
        params.addBodyParameter("pageSize",Constant.PAGESIZE+"");
        params.addBodyParameter("pageNum",pageNum+"");
        sendToServer(params);
    }


    @Override
    public void onSuccess(String result) {
        super.onSuccess(result);
        YiJuAndYiShuoResponse yiJuAndYiShuoResponse=gson.fromJson(result,YiJuAndYiShuoResponse.class);
        callback.onSuccess(yiJuAndYiShuoResponse);
    }
}
